#pragma once
#include <spdlog/logger.h>
#include <setting.pb.h>
#include <qapplication.h>
#include <common_header.h>
#include <utl/vector.h>
#include <sdl_class.h>
#include <gui/GuiSDL.h>
#include <utl/memory.h>

namespace primary
{
	using SettingChangedFN = void (*)(Setting&,u32);

	enum SettingChangedMask
	{
		SCM_TITLE = 0x0001,
		SCM_ICON = 0x0002,
		SCM_FONT = 0x0004,
	};

	class Application
	{
	public:
		Application();
		~Application();
		static Application& instance();
		void save_setting(u32 mask);
		u32 bind_setting(SettingChangedFN fn);
		void unbind_setting(u32 id);
		void unbind_setting(SettingChangedFN fn);
		void setting_editor();
		void run();
	public:
		spdlog::logger logger;
		SDL sdl;
		sdlWindow main_window;
		sdlRenderer main_renderer;
		utl::unique_ptr<GuiSDL> gui;
	private:
		Setting setting;
		utl::vector<SettingChangedFN> setting_changed_callbacks;
		QApplication q_app;
		
	private:
		void setting_changed(u32 mask);
	};
}